import net.aetherial.context.group.*;

class net.aetherial.context.group.Member
{
	public var name:String;
	public var iconUrl:String;
	public var updates:Array;
	
	public function Member ()
	{
		updates = new Array ();
	}
	
	public function getDateByString (dateString:String)
	{
		// 2008-02-18 17:10:32

		var array:Array = dateString.split (" ");
		var dateArray:Array = array[0].split ("-");
		var timeArray:Array = array[1].split (":");
		
		var newDate:Date = new Date ();
		
		newDate.setFullYear (dateArray[0], dateArray[1] - 1, dateArray[2]);
		newDate.setHours (timeArray[0], timeArray[1], timeArray[2]);
		
		return newDate;
	}
	
	public function addUpdate (dateString:String, field:String, value:String)
	{
		var update:Object = new Object ();
		update.field = field;
		update.value = value;
		
		update.date = this.getDateByString (dateString);
		
		this.updates.push (update);
	}
	
	public function toString ()
	{
		var string:String = "Member " + name + newline;
		
		for (var i = 0; i < this.updates.length; i++)
		{
			var update:Object = this.updates[i];
		
			string += " " + update.date + ": " + update.field + " = " + update.value + newline;
		}
		
		return string;
	}
}
